import "./register.css";

export default function RegisterInvite() {
    const params = $state.params;
    const { suppName, token } = params || {};

    //从邀请链接过来第一时间要校验token
    function verificationToken() {
        ZenUI.SL(60);
        let url = `/store/api/invite/verificationToken`;
        let data = {
            token: params.token
        };
        let headerConfig = {
            contentType: 1
        };
        REST.post(url, data, "noInfo", headerConfig).then(
            function(data) {
                ZenUI.HL();
                console.log(data);
                if (data.code == "0000") {
                    $state.go({
                        stateName: "/register",
                        params: {
                            step: 1,
                            registerType: 1,
                            token: params.token
                        }
                    });
                } else {
                    alert(data.message);
                }
            },
            function(error) {
                ZenUI.HL();
                console.log(error);
            }
        );
    }

    return (
        <div className="regi-center">
            <div className="regi-content zen_t-c a-bg-white">
                <div className="zen_il-bl zen_p-50 zen_w-p80 zen_t-l">
                    <div className="a-regi-top-title">注册邀请！</div>
                    <div className="a-regi-bottom zen_p-v-30 zen_m-t-30">
                        <div>尊敬的用户，您好！</div>
                        <div>
                            {params.suppName}
                            诚邀您加入锐竞采购平台，点击下方按钮即可接收邀请并进行注册。锐竞采购平台将为您提供类京东淘宝的试剂耗材采购体验，让采购更有保障，更有效率，帮助您专注您的专注。
                        </div>
                        <div
                            onClick={verificationToken}
                            className={
                                "a-regi-main-btn zen_w-120 zen_t-c zen_h-40 zen_l-h-40 zen_bdr-4 zen_white zen_m-t-30 zen_cur-p"
                            }
                        >
                            <p>接受邀请并注册</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    );
}
